import qiniu from "qiniu";
import config from "../config";
import {exec} from "shelljs"

//需要填写你的 Access Key 和 Secret Key
// qiniu.conf.ACCESS_KEY =config.qiniu.AK;
// qiniu.conf.SECRET_KEY = config.qiniu.SK;
//要上传的空间

export const upload = () => {
    const bucket = "icefire"
    const url ="https://images-na.ssl-images-amazon.com/images/M/MV5BMjA2MDAwOTI0OV5BMl5BanBnXkFtZTcwNjA3NDg1Nw@@._V1.jpg"
    const key ="good.png"
    return new Promise((resolve,reject) => {
        let bash = `qshell fetch ${url} ${bucket} ${key}`
        console.log(bash);
        exec(bash, (code, stdout, stderr) => {
            if (stderr) return reject(stderr)
            if (stdout === 'Fetch error, 504 , xreqid:') return reject(stdout)
            resolve(stdout)
          })
    });
}

